<?php

/*
 *  components
 * 
 *  Copyright (c) 2011
 * 
 *  This file is part of dolpheuscms.
 *  Version: $Id
 *  Created on 17-mei-2011, 17:52:10
 *  Author: Harrie
 * 
 *  This Content Management System is a product of http://www.twidel.nl.
 * 
 *  No manipulation, reproduction or publication in any form without prior written
 *  permission from the copyright holder. Infrigements will result in legal action.
 */

class portfolioComponents extends sfComponents {
    
    /**
     * Function that builds the UL > LI structure of the portfolio tags
     * @param sfWebRequest $request
     */
    public function executeTags(sfWebrequest $request)
    {
        $allTags = Doctrine::getTable('PortfolioTag')->getAllTags();
               
        echo "<ul class='tags'>";
        foreach($allTags as $tag)
        {
            echo "<li><a href='/portfolio#".$tag->getTitle()."'>".$tag->getTitle()."</a></li>";
        }
        echo "</ul>"; 
        
        return sfView::NONE;
    }
       
    /**
     * Function that builds the UL > LI structure of the portfolio items
     * @param sfWebRequest $request 
     */
    public function executePortfolio(sfWebRequest $request)
    {
        //echo "portfolio component";
        $allCats = Doctrine::getTable('Portfolio')->getAllCategoriesWithItems();        
               
        foreach($allCats as $cat)
        {
            echo "<a name=".$cat['PortfolioTag']->getTitle()."><h1>".$cat['PortfolioTag']->getTitle()."</h1></a>"; 
            $allItems = Doctrine::getTable('Portfolio')->getAllItems($cat['PortfolioTag']->getTitle());
                       
            echo "<ul class='portfolio'>";
            foreach($allItems as $item)
            {
                echo "<li>";
                    echo "<div class='portfolio-item-preview'>";
                        echo "<div class='portfolio-item-preview-title'>";
                            echo "<a href='/".$cat['PortfolioTag']->getTitleSlug()."/".$item->getId()."/".$item->getTitleSlug()."'>".$item->getTitle() . "</a><span class='portfolio-item-preview-date'>".$item->getDate()."</span>";
                        echo "</div>";
                        echo "<div class='portfolio-item-preview-image'>";
                        $images = Doctrine::getTable('Portfolio')->getImage($item->getId());
                        foreach($images as $image)
                        {
                            echo "<img src=".$image->getUrl()."  />";
                        }
                        echo "</div>"; 
                        echo "<div class='portfolio-item-preview-text'>";
                            echo "<p>".$item->getContent()."</p>";
                        echo "</div>";
                    echo "</div>";
                echo "</li>";
            }
            echo "</ul>";
        }
        
        return sfView::NONE;
    }
    
    /**
     * Function that builds the slider with portfolio items
     * @param sfWebRequest $request
     */
    public function executeSlider(sfWebRequest $request)
    {
        $portfolio = Doctrine::getTable('Portfolio')->getPortfolioItem($request->getParameter('id'));
        
        echo "<div id='galleria'>";
            foreach($portfolio as $item)
            {
                foreach($item['PortfolioImage'] as $image)
                {
                    echo "<a href='".$image['url']."'><img title='ahahaha' src='".$image['url']."' /></a>";
                }
            }
        echo "</div>";
        echo "<div id='galleria-description'>";
            foreach($portfolio as $item)
            {
                echo "<h1>".$item->getTitle()."</h1>";
                echo "<p>".$item->getContent()."</p>";
            }
        /*echo "
            <p>
                In porta neque in eros congue in consectetur odio pretium. Proin et odio vitae sem semper pulvinar vel sed lorem. 
                Suspendisse potenti. Sed mi tellus, sollicitudin non aliquam ut, dictum eu eros. Vestibulum a dui sit amet erat 
                fermentum tristique vitae ut dolor. Maecenas a neque vel arcu vulputate bibendum. Aliquam orci nibh, iaculis et 
                tempus et, egestas vel metus. Suspendisse in sodales enim. Donec volutpat eleifend lacus id accumsan. Nullam gravida 
                diam eget ligula dapibus pellentesque. Quisque ligula augue, rhoncus sit amet convallis at, porttitor ut orci.
            </p>
            <p>
                Quisque vulputate fringilla molestie. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per 
                inceptos himenaeos. Maecenas iaculis nisi sit amet dolor imperdiet non bibendum ipsum sollicitudin. Cum sociis 
                natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Praesent consectetur mollis enim, sed 
                mollis arcu blandit non. Nunc urna erat, placerat semper dictum sed, elementum ac ante. Nulla id ipsum nisi, non 
                pellentesque dui. In vestibulum velit vitae nisl dignissim consectetur. Pellentesque porta lobortis turpis, non 
                euismod eros molestie ac. Mauris id odio enim. Etiam at nisi sed tellus cursus scelerisque at ut nisl. Quisque 
                vitae magna lectus, ut sodales augue. In congue elit id felis viverra accumsan. Mauris et tempus sapien. Fusce 
                suscipit, tortor in fermentum semper, justo nibh porta ante, ac mattis velit est vitae nisi. In aliquam mollis 
                tincidunt. Curabitur ligula lectus, ultricies eu tristique nec, bibendum id sem. Duis est libero, varius nec rutrum ut, 
                tincidunt sodales sem. Duis adipiscing posuere eros id vulputate.
            </p>
            <p>
                Pellentesque nec ligula arcu, sit amet elementum sapien. Vivamus consequat gravida felis, in faucibus justo dictum ac. 
                Aenean eros purus, facilisis egestas commodo et, rutrum sit amet nisi. Aliquam sit amet sodales ipsum. Morbi mattis vehicula 
                odio, eu vestibulum massa aliquet sit amet. Sed laoreet nibh sit amet augue posuere tristique. Aenean bibendum metus in urna 
                elementum posuere. In aliquet sapien commodo diam pharetra porttitor sit amet at odio. Sed lacinia odio nec sapien sodales a 
                hendrerit quam eleifend. Nam porttitor magna et ipsum commodo eleifend. Duis varius adipiscing dolor. Sed leo arcu, vulputate 
                nec blandit quis, malesuada sit amet diam. Proin vel sapien dolor, ut vehicula felis. Morbi commodo cursus rhoncus.
            </p>";*/
        echo "</div>";
        
        
        //echo "slider hiero";
        
        return sfView::NONE;
    }
    
}
